<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id="id1" type="number" min='50' max='100' required>
    <button onclick="myfunction()">验证</button>

    <p id="demo"></p>

    <script>
        function myfunction(){
            var ipt=document.getElementById('id1')
            if(!ipt.checkValidity()){
                document.getElementById('demo').innerHTML=ipt.validationMessage;

            }else{
                document.getElementById('demo').innerHTML='输入正确'
            }
        }
    </script>
</body>
</html>